fix: add TTY detection before TUI fallbacks to prevent agent/CI hangs#949
fix: add TTY detection before TUI fallbacks to prevent agent/CI hangs#949jesseturner21 merged 2 commits intomainfrom
Conversation
When commands are invoked without flags in non-interactive environments (CI, piped stdin, agent automation), the CLI falls through to Ink TUI rendering which hangs indefinitely. Add a requireTTY() guard at every TUI entry point that checks process.stdout.isTTY and exits with a helpful error message directing users to --help for non-interactive flags. Closes #685
Package TarballHow to installnpm install https://github.com/aws/agentcore-cli/releases/download/pr-949-tarball/aws-agentcore-0.10.0.tgz |
|
The guard checks This is observable in the PR's own test plan. For
So CI/agent environments typically have both streams non-TTY, so the check happens to fire there, but the behavior on an interactive terminal with piped stdin (the canonical repro) is unchanged. Options to fix:
Option 1 or 2 is probably what you want. It would also be worth actually running the test-plan commands against the built CLI (not just |
The hang from #685 is caused by stdin not being a TTY (Ink reads keyboard input from stdin), not stdout. Check both stdin and stdout so the guard fires for piped stdin, redirected stdout, and CI environments where both are non-TTY.
|
Good catch — fixed in 03d3b3f. The guard now checks both Verified with the updated bundle:
|
Coverage Report
|
Problem
When
agentcorecommands are invoked without flags in a non-interactive environment (CI, piped stdin, agent automation), the CLI falls through to Ink TUI rendering. Without a TTY attached, the process hangs indefinitely because there is no terminal to interact with — the only recovery is a timeout or SIGKILL.Reproduction:
Fix
Add a
requireTTY()guard function that checksprocess.stdout.isTTYbefore launching any Ink TUI flow. When no TTY is detected and no CLI-mode flags are present, the CLI prints a clear error message and exits with code 1:The guard is applied at all 17 TUI entry points:
agentcore(fullscreen TUI)create,deploy,invoke,dev --no-browser,add,removecommandsCLI-mode paths (flag-based invocation) are completely unaffected —
agentcore create --name myproject --defaults --jsoncontinues to work in non-TTY environments.Test plan
echo "" | agentcore— prints error + exits 1 (was: hang)echo "" | agentcore create— prints error + exits 1 (was: hang)echo "" | agentcore deploy— prints error + exits 1 (was: hang)echo "" | agentcore add— prints error + exits 1 (was: hang)echo "" | agentcore remove— prints error + exits 1 (was: hang)echo "" | agentcore invoke— prints error + exits 1 (was: hang)echo "" | agentcore create --name test --defaults --dry-run --json— still works (CLI mode unaffected)Closes #685